package day15;

//手套
public class oj2 {
    public int findMinimum(int n, int[] left, int[] right) {
        // write code here
        int leftSum = 0;
        int rightSum = 0;
        int sum = 0;
        int leftMin = Integer.MAX_VALUE;
        int rightMin = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++) {
            if(left[i]*right[i] == 0) {
                sum = sum +right[i] + left[i];
            } else {
                leftSum += left[i];
                if(leftMin>left[i]) {
                    leftMin = left[i];
                }
                rightSum += right[i];
                if(rightMin > right[i]) {
                    rightMin = right[i];
                }
            }
        }
        return sum + Math.min(leftSum - leftMin + 1,rightSum - rightMin + 1) +1;
    }
}
